/*=====================================================
 Copyright (C) ETERNAL<iqstar@ms24.hinet.net>
 URL : http://www.et99.net

请仔细阅读以下许可协议。当您使用本软体，您将自动成为本协议的一方并受到本协议的约束。

软体和文档受到台湾及中国大陆著作权法及国际条约的保护。您不得：
a)营利、出租或者出借软体或文档的任何部分。
b)反向工程、分解、反编译或者企图察看软体的源代码作为商业用途。
c)修改或者改变软体，或者与其他程式结合。

许可人保留软体及文档的所有权利和权益。您不能通过本许可协定获得软体的任何所有权和知识产权。
===================================================== */
var messput = new Array;
var sum = 0, lastspeed = 0, set_lock1 = 0, set_lock2 = 0, set_lock3 = 0, set_lock4 = 0, chat_time = 15000;

function goldset(fman, cman, talkms, hero, a1) {
    //for (var line=19;line>=0;line--) {messput[line+1]=messput[line];}
    //alert(talkms);
    var now = new Date();
    var bg = "";
    var table_bg = "";
    var temp_tag = "";
    var temp_tag1 = "";
    if (cman == "1") {
        bg = "#66ccff";
    }
    if (cman == "0") {
        bg = "#ffffff"
    }
    if (cman == "2") {
        bg = "#ffcc00"
    }
    if (sum == 0) {
        message_cls(chat_view);
    }
    if (cman == "3") {
        table_bg = "bgcolor=\"#00400A\"";
        temp_tag = "(私) <a href=\"javascript:parent.parent.parent.yesname('" + a1 + "');parent.chat_in.document.f1.chat_temp.focus()\" target=chat_in>" + a1 + "</a> to ";
    }
    if (hero == "1") {
        temp_tag1 = "<font color=#FFFF33>[英雄]</font>";
    }
    messput[0] = `<div><span style="color:${bg}} ">
<strong>${temp_tag1 + temp_tag}
<a href="javascript:parent.parent.parent.yesname('${fman}');parent.chat_in.document.f1.chat_temp.focus()" target=chat_in>${fman}</a> ：${talkms}</strong><span class="text-white">(${now.getHours()}:${now.getMinutes()}:${now.getSeconds()})</div></span>`;
    chat_view.document.write(messput[0]);
    if (sum == 495) {
        chat_view.document.write('<div align=left><table class="hero-table"><tr><td class="b1"><B>离更新页面还有5行</B>(' + now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds() + ')</td></tr><tr><td width="100%" height="1" bgcolor="#A2A9B8"></td></tr></table></div>');
    }
    sum++;
    chat_view.scroll(0, 65535);
    if (sum == 500) {
        sum = 0;
    }
};

function message_cls(a, bline) {
    var s = "";
    if (a == null) {
        s = parent.wog_view;
    } else {
        s = a;
    }
    if (bline == null) {
        bline = 2;
    }
    s.document.close();
    s.document.write('<html>');
    s.document.write('<head>');
    s.document.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
    s.document.write('<link rel="stylesheet" href="./../css/wog_infinity/main.css?t="' + new Date().getTime() + '>');
    s.document.write('</head>');
    s.document.write('<body>');
};

function chat_lock(type) {
    var f = chat_in.document.f1;
    switch (type) {
        case 1:
            if (set_lock1 == 0) {
                set_lock1 = 1;
                f.set_lock1.value = "1";
            } else {
                set_lock1 = 0;
                f.set_lock1.value = "0";
            }
            break;
        case 2:
            if (set_lock2 == 0) {
                set_lock2 = 1;
                f.set_lock2.value = "1";
            } else {
                set_lock2 = 0;
                f.set_lock2.value = "0";
            }
            break;
        case 3:
            if (set_lock3 == 0) {
                set_lock3 = 1;
                f.set_lock3.value = "1";
            } else {
                set_lock3 = 0;
                f.set_lock3.value = "0";
            }
            break;
        case 4:
            if (set_lock4 == 0) {
                set_lock4 = 1;
                f.set_lock4.value = "1";
            } else {
                set_lock4 = 0;
                f.set_lock4.value = "0";
            }
            break;
    }
    var temp_message = "";
    if (set_lock1 == 1) {
        temp_message += "‘<font color=#80ff80>一般频关闭中</font>’";
    }
    if (set_lock2 == 1) {
        temp_message += "‘<font color=#80ff80>私频关闭中</font>’";
    }
    if (set_lock3 == 1) {
        temp_message += "‘<font color=#80ff80>公会频关闭中</font>’";
    }
    if (set_lock4 == 1) {
        temp_message += "‘<font color=#80ff80>队频关闭中</font>’";
    }
    if (temp_message != "") {
        goldset("系统", "2", "<font color=red>" + temp_message + "，请在频道设定中设定频道开启聊天</font>", "0");
    }
};

function chat_set() {
    var str = '';
    var lock_ch1 = "", lock_ch2 = "", lock_ch3 = "", lock_ch4 = "";
    var temp_f = "";
    if (parent.parent.UI.set_frame == 1) {
        temp_f = "parent.wog_view.frame_chat";
    } else {
        temp_f = "parent.foot.frame_chat";
    }
    if (set_lock1 == 1) {
        lock_ch1 = "checked";
    }
    if (set_lock2 == 1) {
        lock_ch2 = "checked";
    }
    if (set_lock3 == 1) {
        lock_ch3 = "checked";
    }
    if (set_lock4 == 1) {
        lock_ch4 = "checked";
    }
    str += '<table bgcolor=#000000 width="300">';
    str += '<tr><td><input type="checkbox" name="lock_chat" onclick="' + temp_f + '.chat_lock(1);" ' + lock_ch1 + '>关闭一般频</td>';
    str += '<td><input type="checkbox" name="lock_chat" onclick="' + temp_f + '.chat_lock(2);" ' + lock_ch2 + '>关闭私频</td></tr>';
    str += '<tr><td><input type="checkbox" name="lock_chat" onclick="' + temp_f + '.chat_lock(3);" ' + lock_ch3 + '>关闭公会频</td>';
    str += '<td><input type="checkbox" name="lock_chat" onclick="' + temp_f + '.chat_lock(4);" ' + lock_ch4 + '>关闭队频</td></tr>';
    str += '<tr><td colspan="2"><a href="javascript:' + temp_f + '.chat_set_close();" target="mission">关闭</a></td></tr>';
    str += '</table>';
    parent.parent.parent.f.getElementById("wog_chat_set").innerHTML = str;
};

function chat_set_close() {
    parent.parent.f.getElementById("wog_chat_set").innerHTML = "";
};

function chat_refresh() {
    if (!set_lock1 || !set_lock2 || !set_lock3 || !set_lock4) {
        chat_list.document.location = "./wog_chat_list.php?lastspeed=" + lastspeed + "&set_lock1=" + set_lock1 + "&set_lock2=" + set_lock2 + "&set_lock3=" + set_lock3 + "&set_lock4=" + set_lock4;
    }
    window.setTimeout("chat_refresh()", chat_time);
};
window.setTimeout("chat_refresh()", chat_time);